﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using StackExchange.Redis;

namespace SignalRTest
{
    public class User1Hub : Hub
    {
        public string GetUserName()
        {
            var cookieSessionId = Context.RequestCookies["singnalrSessionId"];
            if (cookieSessionId == null)
            {
                return null;
            }

            string sessionId = cookieSessionId.Value;

            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("47.106.207.95:6379,password=123456"))
            {
                IDatabase db = redis.GetDatabase(); 
                string name = db.StringGet("user_login_singnalrSessionId_" + sessionId);

                return name;
            }
        }
    }
}